﻿using CatUtils.Utils.Currency.IoUtils;
using CatUtils.Utils.Helper;
using CatUtilsDll.Utils.Currency.WebUtils;

using SinaImgUpload.Helper.ViewHelper;
using SinaImgUpload.SainTool.LocalTool;
using SinaImgUpload.SinaUpload.LocalTool;
using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace SinaImgUpload.UserView
{
    public partial class EnhanceControl : UserControl
    {
        public EnhanceControl()
        {
            InitializeComponent();
            InitView();
        }

        private void InitView()
        {
            for (double i = 0.1; i <= 2.1; i += 0.1)
            {
                comboBox2.Items.Add(i.ToString("F1"));
            }
            comboBox2.SelectedIndex = 4;
        }

        private void button16_Click(object sender, EventArgs e)
        {
            new ClearWithSize().XmlFile(FileHelper.SelectFile(), Convert.ToSingle(comboBox2.Text));
        }

        private void button17_Click(object sender, EventArgs e)
        {
            new ClearWithSize().XmlFloder(FloderHelper.SelectFloder(), Convert.ToSingle(comboBox2.Text));
        }

        private string ExcludeKeysPath = "";

        private void button18_Click(object sender, EventArgs e)
        {
            if (ExcludeKeysPath == "")
                return;
            new ClearWithPixivExclude().HandleXml(FileHelper.SelectFile(), ExcludeKeysPath);
        }

        private void button19_Click(object sender, EventArgs e)
        {
            if (ExcludeKeysPath == "")
                return;
            new ClearWithPixivExclude().HandleXmlFloder(FloderHelper.SelectFloder(), ExcludeKeysPath);
        }

        private void button20_Click_1(object sender, EventArgs e)
        {
            ExcludeKeysPath = FileHelper.SelectFile();
            label3.Text = string.Format("当前加载词库：{0}", FileNameHelper.GetFileNameWithoutExtension(ExcludeKeysPath));
        }

        private void button2_Click(object sender, EventArgs e)
        {
            new SainListHelper().ExportBedXmlToList(FileHelper.SelectFile());
        }

        private void button3_Click(object sender, EventArgs e)
        {
            new SainListHelper().ExportBedXmlFloderToList(FloderHelper.SelectFloder());
        }

        private void button1_Click(object sender, EventArgs e)
        {
            new ClearWithPixivId().SingleXmlFile(FileHelper.SelectFile(), textBox1.Text);
        }

        private void button4_Click(object sender, EventArgs e)
        {
            new ClearWithPixivId().ClearXmlWithFloder(FloderHelper.SelectFloder(), textBox1.Text);
        }

        private void button5_Click(object sender, EventArgs e)
        {
            // new LocalData().ImportSinaBed(FileHelper.SelectFile());
        }

        private void button6_Click(object sender, EventArgs e)
        {
            Console.WriteLine("此功能已经被删除。过去为清理xml数据。");
        }

        private void button7_Click(object sender, EventArgs e)
        {
            new ClearListRepeat().ClearSingleXml(FileHelper.SelectFile());
        }

        private void button8_Click(object sender, EventArgs e)
        {
            new ClearListRepeat().ClearXmlWithFloder(FloderHelper.SelectFloder());
        }

        private void button9_Click(object sender, EventArgs e)
        {
            new ClearWithCount().ClearXmlWithFile(FileHelper.SelectFile(), textBox2.Text);
        }

        private void button10_Click(object sender, EventArgs e)
        {
            new ClearWithCount().ClearXmlWithFloder(FloderHelper.SelectFloder(), textBox2.Text);
        }

        private void button11_Click(object sender, EventArgs e)
        {
            new ClearImg().ClearSingleFile(FileHelper.SelectFile());
        }

        private void button12_Click(object sender, EventArgs e)
        {
            new ClearImg().ClearWithFloder(FloderHelper.SelectFloder());
        }

        private void button13_Click(object sender, EventArgs e)
        {
            string FilePath = FileHelper.SelectFile();
            List<string> ImgLinkList = FileHelper.ReadAllLine(FilePath);
            int DownloadComplted = 0;
            string FloderPath = StaticValue.TempPath + FileNameHelper.GetFileNameWithoutExtension(FilePath) + "\\";
            FloderHelper.FloderExits(FloderPath, true);
            foreach (var item in ImgLinkList)
            {
                Console.WriteLine("总计{0},已下载{1}", ImgLinkList.Count, DownloadComplted++);
                new WebHelper().DownloadToFloder(item, FloderPath);
            }
            new MessageHelper().OpenFloderAlert(FloderPath);
        }

        private void button15_Click(object sender, EventArgs e)
        {
            new ClearNoneSinaImg().ClearSingleFile(FileHelper.SelectFile());
        }

        private void button21_Click(object sender, EventArgs e)
        {
            new ClearNoneSinaImg().ClearFloder(FloderHelper.SelectFloder());
        }
    }
}